package cn.kgc.dto;

import cn.kgc.commons.util.AddGroup;
import cn.kgc.commons.util.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;

/**
 * <p>添加描述信息</p>
 *
 * @author 卢传琪
 *
 * 新增更新的时候使用同一个类 接收前端传入的参数
 *
 * 新增和更新的后端验证规则是不同的，使用JSR303验证时，需要区分是新增还是更新的操作
 */

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel
@ToString
public class PmsBrandDTO {
    @ApiModelProperty(name = "id", value = "主键", dataType = "int")
    @NotNull(message = "id:主键不能为空", groups = UpdateGroup.class)
    private Long id; //主键


    @ApiModelProperty(name = "name", value = "品牌名", dataType = "java.lang.String")
    @NotBlank(message = "name:品牌名不能为空",groups = {UpdateGroup.class, AddGroup.class})
    @Length(min = 2, max = 50, message = "name:品牌名长度必须在2-50之间",groups = {UpdateGroup.class, AddGroup.class})
    private String name;    //品牌名


    @ApiModelProperty(name = "logo", value = "品牌logo地址", dataType = "java.lang.String")
    private String logo;    //品牌logo地址


    @ApiModelProperty(name = "descript", value = "介绍", dataType = "java.lang.String")
    private String descript;    //介绍


    @ApiModelProperty(name = "firstLetter", value = "检索首字母", dataType = "java.lang.String")
    @Pattern(regexp = "[a-zA-Z]{1}", message = "firstLetter:检索首字母必须是一个字母,且长度必须是1"
            ,groups = {UpdateGroup.class, AddGroup.class})
    private String firstLetter;    //检索首字母

    @ApiModelProperty(name = "sort", value = "排序", dataType = "java.lang.Integer")
    @Min(value = 0, message = "sort:排序必须大于等于0",groups = {UpdateGroup.class, AddGroup.class})
    @Max(value = 10, message = "sort:排序必须小于等于100",groups = {UpdateGroup.class, AddGroup.class})
    private Integer sort;    //排序

    private int version;   //版本
}
